package com.WebMentorPro.system.service.impl;

import com.WebMentorPro.system.common.ErrorCode;
import com.WebMentorPro.system.exception.BusinessException;
import com.WebMentorPro.system.mapper.MeetingMapper;
import com.WebMentorPro.system.model.dto.meeting.MeetingQueryByTeacherRequest;
import com.WebMentorPro.system.model.dto.meeting.MeetingQueryRequest;
import com.WebMentorPro.system.model.entity.Meeting;
import com.WebMentorPro.system.model.vo.ActivityVO;
import com.WebMentorPro.system.model.vo.MeetingVO;
import com.WebMentorPro.system.service.MeetingService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author bianxiaoyao
* @description 针对表【meeting(开会表)】的数据库操作Service实现
* @createDate 2024-11-24 11:24:42
*/
@Service
public class MeetingServiceImpl extends ServiceImpl<MeetingMapper, Meeting>
    implements MeetingService {

    @Resource
    private MeetingMapper meetingMapper;

    @Override
    public Page<MeetingVO> getQueryWrapper(Page<MeetingVO> pageParam, MeetingQueryRequest meetingQueryRequest) {
        // 自定义分页查询
        List<MeetingVO> meetingVOList = meetingMapper.getQuery(pageParam, meetingQueryRequest);
        if (meetingVOList == null) {
            throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询失败");
        }
        // 设置分页结果
        pageParam.setRecords(meetingVOList);
        return pageParam;
    }

    @Override
    public Page<MeetingVO> getQueryByTeacher(Page<MeetingVO> pageParam, MeetingQueryByTeacherRequest meetingQueryByTeacherRequest, String teacherName) {
        // 自定义分页查询
        List<MeetingVO> meetingVOList = meetingMapper.getQueryByTeacher(pageParam, meetingQueryByTeacherRequest, teacherName);
        if (meetingVOList == null) {
            throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询失败");
        }
        // 设置分页结果
        pageParam.setRecords(meetingVOList);
        return pageParam;
    }
}




